<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>APR (Airport Rhapsody): monAirportRhapsodyPo.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">APR (Airport Rhapsody)
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">Implementation based on monitors</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('mon_airport_rhapsody_po_8h.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">monAirportRhapsodyPo.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Problem name: Airport rhapsody.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;stdbool.h&gt;</code><br/>
<code>#include &quot;<a class="el" href="prob_data_struct_8h_source.html">probDataStruct.h</a>&quot;</code><br/>
</div>
<p><a href="mon_airport_rhapsody_po_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ad9cef5ab0539f9629345a5bfd9825fde"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mon_airport_rhapsody_po_8h.html#ad9cef5ab0539f9629345a5bfd9825fde">takeARest</a> (unsigned int k)</td></tr>
<tr class="memdesc:ad9cef5ab0539f9629345a5bfd9825fde"><td class="mdescLeft">&#160;</td><td class="mdescRight">Take a rest.  <a href="#ad9cef5ab0539f9629345a5bfd9825fde">More...</a><br/></td></tr>
<tr class="separator:ad9cef5ab0539f9629345a5bfd9825fde"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a28ba37f91550bf4843c591fbb5043e9f"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mon_airport_rhapsody_po_8h.html#a28ba37f91550bf4843c591fbb5043e9f">tryToCollectABag</a> (unsigned int k, <a class="el" href="struct_b_a_g.html">BAG</a> *p_bag)</td></tr>
<tr class="memdesc:a28ba37f91550bf4843c591fbb5043e9f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Try to collect a bag.  <a href="#a28ba37f91550bf4843c591fbb5043e9f">More...</a><br/></td></tr>
<tr class="separator:a28ba37f91550bf4843c591fbb5043e9f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a232ad1c8d398f98b256ddb8cfcd9a4b0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mon_airport_rhapsody_po_8h.html#a232ad1c8d398f98b256ddb8cfcd9a4b0">carryItToAppropriateStore</a> (unsigned int k, <a class="el" href="struct_b_a_g.html">BAG</a> *p_bag)</td></tr>
<tr class="memdesc:a232ad1c8d398f98b256ddb8cfcd9a4b0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Carry it to the appropriate store.  <a href="#a232ad1c8d398f98b256ddb8cfcd9a4b0">More...</a><br/></td></tr>
<tr class="separator:a232ad1c8d398f98b256ddb8cfcd9a4b0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a689938020418f2ddd134d488accf7e4e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mon_airport_rhapsody_po_8h.html#a689938020418f2ddd134d488accf7e4e">noMoreBagsToCollect</a> (unsigned int k)</td></tr>
<tr class="memdesc:a689938020418f2ddd134d488accf7e4e"><td class="mdescLeft">&#160;</td><td class="mdescRight">No more bags to collect.  <a href="#a689938020418f2ddd134d488accf7e4e">More...</a><br/></td></tr>
<tr class="separator:a689938020418f2ddd134d488accf7e4e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Problem name: Airport rhapsody. </p>
<p>(interface file)</p>
<p>Concept: António Rui Borges</p>
<p>Synchronization based on monitors. Both threads and the monitor are implemented using the pthread library which enables the creation of a monitor of the Lampson / Redell type.</p>
<p>Definition of the operations carried out by the porter thread: </p>
<ul>
<li>take a rest </li>
<li>try to collect a bag </li>
<li>carry it to the appropriate store </li>
<li>no more bags to collect.</li>
</ul>
<dl class="section author"><dt>Author</dt><dd>António Rui Borges - December 2013 </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a232ad1c8d398f98b256ddb8cfcd9a4b0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void carryItToAppropriateStore </td>
          <td>(</td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>k</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_b_a_g.html">BAG</a> *&#160;</td>
          <td class="paramname"><em>p_bag</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Carry it to the appropriate store. </p>
<p>The porter checks the bag identification. If it is unknown, he issues an error message. He then checks the passenger flight situation. If she has this airport as her final destination, he deposits the bag on the belt conveyor and informs the passenger. Otherwise, he takes the bag to the storeroom for temporary storage. He also updates statistical data in both cases.</p>
<p>State should be saved.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">k</td><td>plane landing number </td></tr>
    <tr><td class="paramname">p_bag</td><td>pointer to the location where the retrieved bag should be stored </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a689938020418f2ddd134d488accf7e4e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void noMoreBagsToCollect </td>
          <td>(</td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>k</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>No more bags to collect. </p>
<p>The porter goes back to his office.</p>
<p>State should be saved.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">k</td><td>plane landing number </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ad9cef5ab0539f9629345a5bfd9825fde"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void takeARest </td>
          <td>(</td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>k</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Take a rest. </p>
<p>The porter reads the newspaper while waiting for next assignment. He waits while not all the N passengers have left the plane which has just landed. He proceeds otherwise.</p>
<p>No state should be saved.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">k</td><td>plane landing number </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a28ba37f91550bf4843c591fbb5043e9f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool tryToCollectABag </td>
          <td>(</td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>k</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_b_a_g.html">BAG</a> *&#160;</td>
          <td class="paramname"><em>p_bag</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Try to collect a bag. </p>
<p>The porter goes to the plane's hold and checks if there are bags still left to be collected. If so, he picks up one and leaves. If not, and before leaving, he informs the passengers who may be still waiting that there are no more bags left.</p>
<p>State should be saved.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">k</td><td>plane landing number </td></tr>
    <tr><td class="paramname">p_bag</td><td>pointer to the location where the retrieved bag should be stored</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code>, if he has picked up a bag </dd>
<dd>
<code>false</code>, otherwise </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="mon_airport_rhapsody_po_8h.html">monAirportRhapsodyPo.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.3.1 </li>
  </ul>
</div>
</body>
</html>
